package uz.rt.linac;

public class Jaw extends LinacComponent
{
    private double lowerLimit = 0.0;
    private double upperLimit = 0.0;
    private double value = 0.0;
    private double thickness = 0.0;
    private double speed = 0.0;

    public boolean isValid()
    {
        return value >= lowerLimit && value <= upperLimit && lowerLimit <= upperLimit;
    }

    public double getLowerLimit()
    {
        return lowerLimit;
    }

    public void setLowerLimit(double lowerLimit)
    {
        this.lowerLimit = lowerLimit;
    }

    public double getUpperLimit()
    {
        return upperLimit;
    }

    public void setUpperLimit(double upperLimit)
    {
        this.upperLimit = upperLimit;
    }

    public double getValue()
    {
        return value;
    }

    public void setValue(double value)
    {
        this.value = value;
    }

    public double getThickness()
    {
        return thickness;
    }

    public void setThickness(double thickness)
    {
        this.thickness = thickness;
    }

    public double getSpeed()
    {
        return speed;
    }

    public void setSpeed(double speed)
    {
        this.speed = speed;
    }

    @Override
    public boolean equals(Object o)
    {
        if (this == o) return true;
        if (!(o instanceof Jaw)) return false;

        Jaw jaw = (Jaw) o;

        return distanceToSource.compareTo(jaw.getDistanceToSource()) == 0 && Double.compare(jaw.lowerLimit,
                                                                                             lowerLimit) == 0 && Double.compare(
                jaw.speed, speed) == 0 && Double.compare(jaw.thickness, thickness) == 0 && Double.compare(
                jaw.upperLimit, upperLimit) == 0 && Double.compare(jaw.value, value) == 0;

    }

    @Override
    public int hashCode()
    {
        int result;
        long temp;
        temp = lowerLimit != +0.0d ? Double.doubleToLongBits(lowerLimit) : 0L;
        result = (int) (temp ^ (temp >>> 32));
        temp = upperLimit != +0.0d ? Double.doubleToLongBits(upperLimit) : 0L;
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        temp = value != +0.0d ? Double.doubleToLongBits(value) : 0L;
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        temp = (distanceToSource != null) ? distanceToSource.hashCode():0L;
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        temp = thickness != +0.0d ? Double.doubleToLongBits(thickness) : 0L;
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        temp = speed != +0.0d ? Double.doubleToLongBits(speed) : 0L;
        result = 31 * result + (int) (temp ^ (temp >>> 32));
        return result;
    }
}
